
//
//  U9TabBarButton.m
//  U9WatchGame
//
//  Created by u9-baken on 2019/2/21.
//  Copyright © 2019 UUU9. All rights reserved.
//

#import "U9TabBarButton.h"

#define kImageRatio 0.7
@implementation U9TabBarButton

+ (instancetype)tabBarButton{
    U9TabBarButton *button = [[self alloc] init];
    return button;
}

- (instancetype)init
{
    if (self = [super init]) {
        self.titleLabel.font = [UIFont systemFontOfSize:10];
        
        [self setTitleColor:UIColorFromRGB(kDarkFontColor) forState:UIControlStateNormal];
        [self setTitleColor:UIColorFromRGB(0xed4a4a) forState:UIControlStateSelected];
        self.imageView.contentMode = UIViewContentModeCenter;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;

    }
    return self;
}


-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    CGFloat imageX = 0;
    CGFloat imageY = 0;
    CGFloat imageWidth = contentRect.size.width ;
    CGFloat imageHeight = contentRect.size.height * kImageRatio;
    return CGRectMake(imageX, imageY, imageWidth, imageHeight);
    
}



-(CGRect)titleRectForContentRect:(CGRect)contentRect{
    CGFloat titleX = 0;
    CGFloat titleY = contentRect.size.height * kImageRatio;
    CGFloat titleWidth = contentRect.size.width ;
    CGFloat titleHeight = contentRect.size.height * (1 - kImageRatio)-10;
    return CGRectMake(titleX, titleY, titleWidth, titleHeight);
    
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
